home *** CD-ROM | disk | FTP | other *** search
- // DO NOT import this into the global namespace, but instead
- // import it into your own namespace wrapper
-
- var EXPORTED_SYMBOLS = ["EventSource"];
-
- Components.utils.import("resource://glydo/utils/prototype_xul_1_6_0_3_modified.jsm");
-
- var EventSource = Prototype.Class.create({
- initialize: function() {
- this.listeners = [];
- },
-
- addListener: function(listener) {
- if (listener) {
- this.listeners.push(listener);
- }
- },
-
- removeListener: function(listener) {
- var found = null;
- for (var i = 0; i < this.listeners.length; ++i) {
- if (this.listeners[i] === listener) {
- found = i;
- }
- }
- if (found !== null) {
- this.listeners.splice(found,1);
- }
- },
-
- fire: function(callback) {
- var args = Prototype.$A(arguments);
- args.shift();
- if (callback) {
- for (var index = 0; index < this.listeners.length; ++index) {
- var listener = this.listeners[index];
- try {
- if (listener[callback])
- listener[callback].apply(listener,args);
- } catch (ex) {
- if (Components) {
- Components.utils.reportError(ex);
- } else {
- throw ex;
- }
- }
- }
- }
- }
- });
-
-